/*
 * @Description: 
 * @FilePath: /STM32F103/USER/bsp/dma.h
 * @Author: Wei Zhou
 * @Github: https://github.com/zromyk
 * @Date: 2021-05-12 20:17:46
 * @LastEditors: Wei Zhou
 * @LastEditTime: 2021-05-12 22:48:08
 * @Copyright: Copyright © 2017 muyiro. All rights reserved.
 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DMA_INIT_H
#define DMA_INIT_H

#include "my_include.h"

typedef struct {
    DMA_TypeDef             *DMAx;
    uint32_t                RCC_Periph_DMA;

    DMA_Channel_TypeDef     *tx_channel;
    IRQn_Type               tx_IRQn;
    uint32_t                tx_FLAG_TC;

    DMA_Channel_TypeDef     *rx_channel;
    IRQn_Type               rx_IRQn;
    uint32_t                rx_FLAG_TC;
} DMA_Dev;

/**
 * @brief  DMA Tx initialize.
 * @param  *dma:        point to a DMA_Dev.
 * @param  DR_addr:     peripheral addr.
 * @param  *tx_buf:     point to a send buffer.
 * @param  tx_buf_size: size of send buffer.
 * @retval None
 */
void dma_tx_init(DMA_Dev *dma, uint32_t DR_addr, uint8_t *tx_buf, uint32_t tx_buf_size);

/**
 * @brief  DMA Rx initialize.
 * @param  *dma:        point to a DMA_Dev.
 * @param  DR_addr:     peripheral addr.
 * @param  *rx_buf:     point to a receive buffer.
 * @param  rx_buf_size: size of receive buffer.
 * @retval None
 */
void dma_rx_init(DMA_Dev *dma, uint32_t DR_addr, uint8_t *rx_buf, uint32_t rx_buf_size);

#endif /* DMA_INIT_H */
